package com.machine.action.buycomponent;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.machine.bean.BuyComponent;
import com.machine.service.user.BuyComponentServiceDao;
import com.opensymphony.xwork2.ActionSupport;

@Component("updateBuyComAction")
@Scope(value = "prototype")
public class UpdateBuyComAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private BuyComponentServiceDao buyComponentServiceDao;
	private BuyComponent buyComponent;
	private List<Integer> buyComponentId = new ArrayList<Integer>();

	public BuyComponentServiceDao getBuyComponentServiceDao() {
		return buyComponentServiceDao;
	}

	@Resource(name = "buyComponentService")
	public void setBuyComponentServiceDao(
			BuyComponentServiceDao buyComponentServiceDao) {
		this.buyComponentServiceDao = buyComponentServiceDao;
	}

	public BuyComponent getBuyComponent() {
		return buyComponent;
	}

	public void setBuyComponent(BuyComponent buyComponent) {
		this.buyComponent = buyComponent;
	}

	public List<Integer> getBuyComponentId() {
		return buyComponentId;
	}

	public void setBuyComponentId(List<Integer> buyComponentId) {
		this.buyComponentId = buyComponentId;
	}

	@Override
	public String execute() throws Exception {

		if (buyComponentId.size() > 0) {
			buyComponent = buyComponentServiceDao.findById(buyComponentId.get(0));
		}
		return SUCCESS;
	}
}
